<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Adicionar Materia</title>
<link rel="stylesheet" href="<c:url value='/css/estilos.css'/>"/>
<script type="text/javascript">
	function validations() {

		if ("" == document.forms.subjectForm.subjectCode.value
				|| "" == document.forms.subjectForm.subjectName.value
				|| "" == document.forms.subjectForm.subjectPeriod.value) {
			alert("todos los campos son requeridos");
			return false;
		}

		return true;
	}
</script>

</head>
<body>
<header> <jsp:include page="items.jsp"></jsp:include> </header>
	<h1>Crear Nueva Materia</h1>

	<c:url var="saveUrl" value="/subject/add" />
	<form:form name="subjectForm" modelAttribute="subjectAttribute"
		method="POST" action="${saveUrl}" onsubmit="return validations();">
		<table>
			<tr>
				<td><form:label path="subjectCode">Código:</form:label></td>
				<td><form:input path="subjectCode" id="subjectCode" /></td>
			</tr>
			<tr>
				<td><form:label path="subjectName">Nombre:</form:label></td>
				<td><form:input path="subjectName" id="subjectName" /></td>
			</tr>
			<tr>
				<td><form:label path="subjectPeriod">Periodo de la Materia:</form:label></td>
				<td><form:select path="subjectPeriod" id="subjectPeriod">
						<form:options items="${subjectPeriodList}" itemLabel="name"
							itemValue="code" />
					</form:select></td>
			</tr>

		</table>

		<input type="submit" value="Guardar" />
	</form:form>

</body>
</html>